package com.systop.asset.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

/**
 * activiti内置了SpringSecurity安全框架，需要配置UserDetailsService Bean。
 * 这里不做过多配置，仅配置该bean即可。
 */
@Configuration
public class UserDetailsServiceConfiguration {
 
    @Bean
    public UserDetailsService userDetailsService() {
        User.UserBuilder users = User.withDefaultPasswordEncoder();
        UserDetails user = users.username("user")
                .password("{noop}pass")
                .authorities("ROLE_ACTIVITI_USER")
                .build();
        return new InMemoryUserDetailsManager(user);
    }
}